<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css" />
<link rel="stylesheet" type="text/css"
	href="css/helpers/jquery.fancybox-thumbs.css" />
<script src="js/jquery-1.11.3.min.js"></script>
<script src="js/jquery.mousewheel-3.0.6.pack.js"></script>
<script type="text/javascript" src="js/jquery.fancybox.js"></script>
<script type="text/javascript"
	src="js/helpers/jquery.fancybox-thumbs.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.zclip.min.js"></script>

<script type="text/javascript" src="js/page.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<!-- <script type="text/javascript" src="js/show_pic.js"></script> -->
<title>动态管理</title>
</head>
<body>
	<jsp:include page="navigation.jsp"></jsp:include>
	<div class="container" style="margin-left: 190px;">
		<div class="topbar-inner">
			<div class="myhead">
				<span class="crumb-name">动态管理</span>
			</div>
		</div>
		<form id="pageForm" action="choicenessinfo" method="post">
			<input type="hidden" value="${ page.pageCount }" id="pageCount"
				name="pageCount" /> <input type="hidden"
				value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
		</form>
		<div style="margin: 20px 20px 20px 20px; text-align: center;">
			<table class="table table-bordered table-hover table-striped">
				<thead>
					<tr>
						<th>发布者</th>
						<th>昵称</th>
						<th>头像</th>
						<th>发布内容</th>
						<th>发布视频</th>
						<th>发布时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${ list }" var="l">
						<tr>
							<td><a href="userdetail?userid=${ l.user.id }">${ l.user.user_name }</a></td>
							<td>${ l.user.appellation }</td>
							<td><c:if
									test="${ l.user.portrait == null || l.user.portrait == '' }">
									<img src="images/defalut.png" />
								</c:if> <c:if
									test="${ l.user.portrait != null && l.user.portrait != '' }">
									<img
										src="http://139.196.188.251:8080/upload/cache/${ l.user.portrait }"
										width="50px" />
								</c:if></td>
							<td><c:if test="${fn:length(l.content) > 25}">${fn:substring(l.content, 0, 23)}...</c:if>
								<c:if test="${fn:length(l.content) <= 25}">${ l.content }</c:if>
							</td>
							<td><c:if test="${ l.video != null && l.video != '' }">
									<div class="input-group">
										<input type="text" class="form-control"
											value="http://139.196.188.251:8080/upload/${ l.video }" /> <img
											class="copy_img" src="images/copy.png"
											style="cursor: pointer; border-top: 1px solid #CCC; border-bottom: 1px solid #CCC; border-right: 1px solid #CCC; border-top-right-radius: 5px; border-bottom-right-radius: 5px;"
											width="34px" height="34px" data-toggle="poppver" title="点击复制"
											data-placement="top" data-content="点击复制" />

<%-- 										<button type="button" id="showvideo" onclick="showvideo('http://139.196.188.251/upload/${ l.video }')" --%>
<!-- 											class="btn btn-default" -->
<!-- 											style="margin-left: 20px; margin-top: 1px;">查看视频</button> -->
									</div>
								</c:if>
								<c:if test="${ l.video == null || l.video == '' }">

									<c:if test="${ l.pics != null && l.pics != '' }">
										<c:set var="pics" value="${fn:split(l.pics, ',') }" />
										<c:forEach items="${ pics }" var="p">
											<%-- 											<a class="fancybox-thumbs" data-fancybox-group="thumb" href="http://139.196.188.251/upload/origin/${ p }"><img src="http://139.196.188.251/upload/origin/${ p }" alt="" width="50px" height="50px"  /></a> --%>
											<img src="http://139.196.188.251:8080/upload/origin/${ p }"
												width="50px" height="50px" />
										</c:forEach>
									</c:if>
								</c:if></td>
							<td><fmt:formatDate value="${ l.create_time }"
									pattern="yyyy-MM-dd HH:mm:ss" type="date" dateStyle="long" /></td>
							<td>
								<c:if test="${ l.chioce == 0 }">
								<a href="javascript:" onclick="toChioce(${ l.id },'你确定要加入精选？')">加入精选</a>
								</c:if>
								<c:if test="${ l.chioce == 1 }">
								<a href="javascript:" onclick="toChioce(${ l.id },'你确定要取消精选？')">取消精选</a>
								</c:if>
								</td>
						</tr>
					</c:forEach>

				</tbody>
			</table>
			<input type="hidden" value="${ page.pageCount }" id="pageCount"
				name="pageCount" /> <input type="hidden"
				value="${ page.pageIndex }" id="pageIndex" name="pageIndex" />
			<c:if test="${ page == null }">
				<div style="font-size: larger;">暂无数据</div>
			</c:if>
			<c:if test="${ page != null && page.pageCount > 1 }">
				<ul id="pagination" class="pagination">

				</ul>
				<script type="text/javascript">
					setPage(document.getElementById("pagination"), parseInt($(
							"#pageCount").val()), parseInt($("#pageIndex")
							.val()));
				</script>
			</c:if>
		</div>
	</div>


	<script>
		$(function() {
			$('.submenu_7_1').addClass('submenu_native');

			$('td>img').click(function() {
				$('.show_big>img').prop('src', $(this).prop('src'));
				$('.show_big').css('display', 'block');
				$('.show_big').focus();
			});
			$('.show_big').focus(function() {
				alert('asdfasdfadsf');
				$(this).css('display', 'none');
			});
			$('.show_big').blur(function() {
				alert('asdfasdfadsf');
				$(this).css('display', 'none');
			});
			
			$('.copy_img').click(function() {
				toCopyBlank($(this).parent().find('input').val());
				$('.copy_img').prop('title', '点击复制');
				$(this).prop('title', '已复制');
			});
			
			$('[data-toggle=popover]').popover();
			
			$('.fancybox-thumbs').fancybox({
				prevEffect : 'none',
				nextEffect : 'none',

				closeBtn  : false,
				arrows    : false,
				nextClick : true,

				helpers : {
					thumbs : {
						width  : 50,
						height : 50
					}
				}
			});

		});
		
			function toChioce(id, message) {
				if (confirm(message)) {
					$.ajax({
						type : 'post',
						url : 'setchioce',
						data : {id: id},
						success : function(data) {
							console.log(data);
							if (data != null) {
								if (data.code == 0) {
									alert('操作成功！');
									window.location.reload();
								} else {
									alert(data.message);
								}
							}
						}
					});
				}
				
			}
	</script>
</body>

</html>